﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Travel.Web.order_detail
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					Guid id=new Guid(Request.Params["id"]);
					ShowInfo(id);
				}
			}
		}
			
	private void ShowInfo(Guid id)
	{
		Travel.BLL.order_detail bll=new Travel.BLL.order_detail();
		Travel.Model.order_detail model=bll.GetModel(id);
		this.lblid.Text=model.id.ToString();
		this.lblorder_id.Text=model.order_id.ToString();
		this.txtprice_id.Text=model.price_id.ToString();
		this.txtroute_numbers.Text=model.route_numbers.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtprice_id.Text))
			{
				strErr+="团编号格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtroute_numbers.Text))
			{
				strErr+="购买数量格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			Guid id= new Guid(this.lblid.Text);
			Guid order_id= new Guid(this.lblorder_id.Text);
			int price_id=int.Parse(this.txtprice_id.Text);
			int route_numbers=int.Parse(this.txtroute_numbers.Text);


			Travel.Model.order_detail model=new Travel.Model.order_detail();
			model.id=id;
			model.order_id=order_id;
			model.price_id=price_id;
			model.route_numbers=route_numbers;

			Travel.BLL.order_detail bll=new Travel.BLL.order_detail();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
